#include <cstring>

#include <iostream>
#include <string>

enum eState {
    eBeforeInclude = 0,
    eInInclude,
    eInBody,
    eFileEnd
};

std::string cutFromStart( const std::string& original, const std::string& spacers )
{
    std::string::const_iterator begin(original.begin());
    std::string::const_iterator end(original.end());
    bool        isFindNonSpace(false);

    while ((not isFindNonSpace) and (begin < end)) {
        isFindNonSpace  =   (std::string::npos == spacers.find(*begin));

        if (not isFindNonSpace) {
            ++begin;
        }
    }

    return original.substr(std::distance(original.begin(), begin), std::string::npos);
}


int main( int argc, char** argv )
{
    eState		state(eBeforeInclude);
    std::string	tmpStr("");

    while (std::getline(std::cin, tmpStr)) {

        std::string trimmedStr(cutFromStart(tmpStr, " \n\r\t"));

        if (true == trimmedStr.empty()) {
            std::cout << std::endl;
            continue;
        }
		
        switch(state) {

            case eBeforeInclude : {

                    if ('#' == *trimmedStr.begin()) {
                        state   =   eInInclude;
                    }

                    break;
            }

            case eInInclude : {

                    if ('#' != *trimmedStr.begin()) {

                        std::cout   << "#ifdef __cplusplus " << std::endl
                                    << "extern \"C\" {" << std::endl
                                    << "#endif//_cplusplus" << std::endl
                                    << std::endl;

                        state   =   eInBody;
                    }

                    break;
            }

            case eInBody : {

                    if (0 == trimmedStr.compare(0, strlen("#endif"), "#endif")) {

                        std::cout   << "#ifdef __cplusplus " << std::endl
                                    << "}" << std::endl
                                    << "#endif//_cplusplus" << std::endl
                                    << std::endl;

                    }

                    break;
            }

            case eFileEnd : {
                    //do nothing
                    break;
            }
        }

        std::cout << tmpStr << std::endl;
    }
}
